package com.community.entity;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.feng.fengDUtil.dao.annotation.ColumnIgnore;
import com.feng.fengDUtil.dao.annotation.Id;
import com.feng.fengDUtil.dao.annotation.Table;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@Data
@Table("a_problem_user")
public class ProblemUser {
	@Id(Id.IdType.uuid)
    private String id;
	
	private String gtype;
	private String uid;
	private Integer num;
	private String result;

	@ColumnIgnore
	private String title;
	@ColumnIgnore
	private String mtype;

	@ColumnIgnore
	private String select_problem;
	@ColumnIgnore
	private String select_result;

	public JSONArray getOptions(){

		if(StringUtils.isNotEmpty(select_problem)){
			JSONArray array = new JSONArray();
			String[] labels = select_problem.split("\\|");
			String[] values = select_result.split("\\|");
			for(int i=0;i<labels.length;i++){
				JSONObject ret = new JSONObject();
				ret.put("label",labels[i]);
				ret.put("value",values[i]);
				array.add(ret);
			}
			return array;
		}
		return null;
	}
}
